<template>
    <div>
        <cvue-dialog
            :dialogVisible="editRoomVisible"
            title="修改宿舍"
            :isShowFoot="true"
            @handleOpen="openDialog"
            @closeDialog="closeDialog"
            @confirmDialog="confirmDialog"
            @handleClose="closeDialog"
            >
            <div  slot="dialogBody">
                <el-form label-width="120px">
                    <el-form-item label="宿舍名称">
                        <el-input v-model="name" maxlength="30"></el-input>
                    </el-form-item>
                     <!-- <el-form-item label="楼层">
                        <el-input-number v-model="floor" :min="1" :max="curDorm.floorCount" ></el-input-number>
                    </el-form-item> -->
                     <el-form-item label="床位">
                         <el-input-number v-model="bedCount" :min="1" :max="1000" ></el-input-number>
                    </el-form-item>
                </el-form>
            </div>
        </cvue-dialog>
    </div>
</template>
<script>
import cvueDialog from '@/components/cvue-dialog'
export default {
    components: {
        cvueDialog
    },
    computed: {
        editRoomVisible () {
            return this.$store.state.room.editRoomVisible
        },
        editRoom () {
            return this.$store.state.room.editRoom
        },
         curDorm () {
            return this.$store.state.dorm.curDorm    
        }
    },
    data () {
        return {
           name: '',
            floor: 1,
            bedCount: 1
        }
    },
    methods: {
       
        openDialog () {
            this.name = this.editRoom.name
            this.floor = this.editRoom.floor
            this.bedCount = this.editRoom.bedCount
        },
        confirmDialog () {
            if (!this.name) {
                this.$message.error('请输入名称')
                return
            }
            var params = {
                name: this.name,
                floor: this.editRoom.floor,
                bedCount: this.bedCount,
                id: this.editRoom.id
            }
            this.$store.dispatch('room/editRoom', params).then(res => {
                this.$message.success('修改成功')
                this.closeDialog()
            })
        },
        closeDialog () {
            this.$store.commit('room/hideEditRoom')
        }
    }
}
</script>
<style scoped>

</style>
